//
//  CustomNavigationController.m
//

#import "CustomNavigationController.h"
#import "UIImage+Tint.h"

@interface CustomNavigationController ()


@end

@implementation CustomNavigationController

- (id)initWithRootViewController:(UIViewController *)rootViewController{
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    }
    
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    CGFloat statusHeight = CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]) + 44;
    if (@available(iOS 13.0, *)) {
       statusHeight = [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager.statusBarFrame.size.height;
    }
    [self.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]
                                                              size:CGSizeMake([UIScreen mainScreen].bounds.size.width,
                                                                              statusHeight)]
                             forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.translucent = YES;
    self.navigationBar.backIndicatorImage = [UIImage imageNamed:@"nva_back"];
    self.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"nva_back"];
    
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    
    UIViewController* topVC = self.topViewController;
    
    return [topVC preferredStatusBarStyle];
    
}

- (UIViewController *)childViewControllerForStatusBarStyle{
    
    return self.topViewController;
}

- (BOOL)shouldAutorotate {
    return [self.visibleViewController shouldAutorotate];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return [self.visibleViewController supportedInterfaceOrientations];
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}

@end
